<template>
	<view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">钢厂：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">接货人业务号：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">接货人：</view>
			<view class="donger-from-item-obj"> <input class="uni-input" focus placeholder="选择钢厂后会自动带出" /></view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">接货人电话：</view>
			<view class="donger-from-item-obj"> <input class="uni-input" focus placeholder="选择钢厂后会自动带出" /></view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">目的地：</view>
			<view class="donger-from-item-obj"> <input class="uni-input" focus placeholder="选择钢厂后会自动带出" /></view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">始发地：</view>
			<view class="donger-from-item-obj"> <input class="uni-input" focus placeholder="请输入始发地" /></view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">货物：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">供应商：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">司机：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">车辆：</view>
			<view class="donger-from-item-obj">
				<picker :value="index" :range="companies">
					<view class="uni-input">{{companies[index]}}</view>
				</picker>
			</view>
		</view>
		
		<view class="dogner-form-item">
			<view class="donger-from-item-label">运费：</view>
			<view class="donger-from-item-obj"> <input class="uni-input" focus placeholder="请输入始发地" /></view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">车头照：</view>
			<view class="donger-from-item-obj">
			</view>
			<view style="width: 100%;">
				<uni-grid show-border="true" @click="menuClick" :data="swipers"></uni-grid>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">车身照：</view>
			<view class="donger-from-item-obj">
			</view>
			<view style="width: 100%;">
				<uni-grid show-border="true" @click="menuClick" :data="swipers"></uni-grid>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">车尾照：</view>
			<view class="donger-from-item-obj">
			</view>
			<view style="width: 100%;">
				<uni-grid show-border="true" @click="menuClick" :data="swipers"></uni-grid>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">货物照：</view>
			<view class="donger-from-item-obj">
			</view>
			<view style="width: 100%;">
				<uni-grid show-border="true" @click="menuClick" :data="swipers"></uni-grid>
			</view>
		</view>
		<view class="dogner-form-item">
			<view class="donger-from-item-label">装车过磅单：</view>
			<view class="donger-from-item-obj">
			</view>
			<view style="width: 100%;">
				<uni-grid show-border="true" @click="menuClick" :data="swipers"></uni-grid>
			</view>
		</view>
		<view class="dogner-form-item" style="border-bottom-width: 0;">
			<view style="width: 100%;">
				<button style="width: 100%;" type="primary">发车</button>
			</view>
		</view>

	</view>
</template>

<script>
	import uniGrid from "@/components/uni-grid/uni-grid.vue";
	export default {
		components: {
			uniGrid
		},
		data() {
			return {
				index: 0,
				companies: ["日照", "吉安娜"],
				swipers: [{
					image: '/static/add.png',
					text: ''
				}],
			};
		},
		methods: {
			getDetail: function(id) {
				tradeService.carDetail(id).then((res) => {
					console.log(JSON.stringify(res.data.data));
					if (res.data.msg) {
						uni.showToast({
							icon: "none",
							title: res.data.msg,
							duration: 2000
						});
					}

					if (res.data.success) {
						this.car = res.data.data;
					}
				});
			},
			save: function() {
				uni.showLoading({
					title: '保存中'
				});
				console.log(JSON.stringify(this.car));
				tradeService.carSave(this.car).then((res) => {
					uni.hideLoading();
					console.log(JSON.stringify(res));

					if (res.data.success) {
						if (res.data.msg) {
							uni.showToast({
								icon: "success",
								title: res.data.msg,
								duration: 2000
							});
						}
						uni.navigateTo({
							url: "/pages/cars/list/list"
						});
					} else {
						if (res.data.msg) {
							uni.showToast({
								icon: "none",
								title: res.data.msg,
								duration: 2000
							});
						}
					}
				});
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			if (option.action === "detail") {
				this.editable = false;
				this.getDetail(option.id);
			} else if (option.action === "add") {
				this.editable = true;
				this.car.id = "";
			} else if (option.action === "edit") {
				this.editable = true;
				this.getDetail(option.id);
			}
		}
	
	}
</script>

<style>

</style>
